﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevComponents.DotNetBar.Keyboard;

namespace Submitter
{
    class NumberKeyboard : KeyboardControl
    {
        private bool _numberOnly;

        public NumberKeyboard()
        {
            this.Keyboard = CreateLayout();
            this.Invalidate();
        }

        public bool NumberOnly
        {
            get { return _numberOnly; }
            set
            {
                _numberOnly = value;
                this.Keyboard = CreateLayout();
                this.Invalidate();
            }
        }

        private Keyboard CreateLayout()
        {
            var keyboard = new Keyboard();
            var klNumLockOn = new LinearKeyboardLayout();

            if (NumberOnly)
            {
                klNumLockOn.AddKey("7", style: KeyStyle.Light);
                klNumLockOn.AddKey("8", style: KeyStyle.Light);
                klNumLockOn.AddKey("9", style: KeyStyle.Light);
                klNumLockOn.AddLine();

                klNumLockOn.AddKey("4", style: KeyStyle.Light);
                klNumLockOn.AddKey("5", style: KeyStyle.Light);
                klNumLockOn.AddKey("6", style: KeyStyle.Light);
                klNumLockOn.AddLine();

                klNumLockOn.AddKey("1", style: KeyStyle.Light);
                klNumLockOn.AddKey("2", style: KeyStyle.Light);
                klNumLockOn.AddKey("3", style: KeyStyle.Light);

                klNumLockOn.AddLine();

                klNumLockOn.AddKey("0", style: KeyStyle.Light);
                klNumLockOn.AddKey("Del", "{Delete}");
                klNumLockOn.AddKey("Backspace", "{BACKSPACE}");
            }
            else
            {

                klNumLockOn.AddKey("q");
                klNumLockOn.AddKey("w");
                klNumLockOn.AddKey("e");

                klNumLockOn.AddKey("r");
                klNumLockOn.AddKey("t");
                klNumLockOn.AddKey("y");
                klNumLockOn.AddKey("u");
                klNumLockOn.AddKey("i");
                klNumLockOn.AddKey("o");
                klNumLockOn.AddKey("p");

                klNumLockOn.AddSpace(5);
                klNumLockOn.AddKey("7", style: KeyStyle.Light);
                klNumLockOn.AddKey("8", style: KeyStyle.Light);
                klNumLockOn.AddKey("9", style: KeyStyle.Light);
                klNumLockOn.AddLine();

                klNumLockOn.AddSpace(5);
                klNumLockOn.AddKey("a");
                klNumLockOn.AddKey("s");
                klNumLockOn.AddKey("d");
                klNumLockOn.AddKey("f");
                klNumLockOn.AddKey("g");
                klNumLockOn.AddKey("h");
                klNumLockOn.AddKey("j");
                klNumLockOn.AddKey("k");
                klNumLockOn.AddKey("l");
                klNumLockOn.AddSpace(6);


                //klNumLockOn.AddSpace();

                klNumLockOn.AddSpace(5);
                klNumLockOn.AddKey("4", style: KeyStyle.Light);
                klNumLockOn.AddKey("5", style: KeyStyle.Light);
                klNumLockOn.AddKey("6", style: KeyStyle.Light);
                klNumLockOn.AddLine();



                
                klNumLockOn.AddKey("Tab", "{TAB}", width:15);
               
                klNumLockOn.AddKey("z");

                klNumLockOn.AddKey("x");

                klNumLockOn.AddKey("c");
                klNumLockOn.AddKey("v");
                klNumLockOn.AddKey("b");


                klNumLockOn.AddKey("n");
                klNumLockOn.AddKey("m");
                klNumLockOn.AddKey("回车", "{Enter}", width:16);

                klNumLockOn.AddSpace(5);
                klNumLockOn.AddKey("1", style: KeyStyle.Light);
                klNumLockOn.AddKey("2", style: KeyStyle.Light);
                klNumLockOn.AddKey("3", style: KeyStyle.Light);

                klNumLockOn.AddLine();

                klNumLockOn.AddKey("删除", "{Delete}", width:21);
                klNumLockOn.AddKey(" ", width:65);
                klNumLockOn.AddKey("Backspace", "{BACKSPACE}", width:21);

                klNumLockOn.AddSpace(5);
                klNumLockOn.AddKey("0", style: KeyStyle.Light);
                klNumLockOn.AddKey("回车", "{Enter}", width:21);
               

                // klNumLockOn.AddKey("Backspace", "{BACKSPACE}");



                // klNumLockOn.AddLine();


                // klNumLockOn.AddLine();

                //  klNumLockOn.AddLine();

            }



            keyboard.Layouts.Add(klNumLockOn);
            return keyboard;

        }

    }
}
